program Project1;

//{$R *.res}
//{$DEFINE D_VISUAL}
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
uses
  Forms,
  SysUtils,
  vis_list in 'stl\vis_list.pas',
  vector in 'stl\vector.pas',
  stl_base in 'stl\stl_base.pas',
  stl_types in 'stl\stl_types.pas',
  stlmain in 'stl\stlmain.pas',
  adaptors in 'adaptors.pas',
  equalizer in 'equalizer.pas' {Eq},
  pl_consts in 'pl_consts.pas',
  tags in 'tags.pas',
  Unit1 in 'Unit1.pas' {PlMain},
  utils in 'utils.pas',
  visuals in 'visuals.pas',
  sample in 'vis_engine\sample.pas',
  sdk in 'vis_engine\sdk.pas',
  vis_engine in 'vis_engine\vis_engine.pas',
  spec_types in 'vis_engine\spec_types.pas',
  f_vises in 'f_vises.pas' {pl_vises},
  trans_ru in 'trans_ru.pas',
  e_log in 'e_log.pas' {Form2},
  plLst in 'plLst.pas' {,
  wides in 'wides.pas'};

var
    params: array of String;
    p_size: Cardinal;
    p_alloc_size: Cardinal;
  procedure RunWithParams;
    procedure p_add(const obj: string);
    begin
      inc(p_size);
      if (p_size > p_alloc_size) then
      begin
        p_alloc_size := p_alloc_size * 2;
        SetLength(params, p_alloc_size);
      end;
      params[p_size - 1] := obj;
    end;
  var
    i: longint;
    ext: string;
  begin
    p_size := 0;
    p_alloc_size := 1;
    SetLength(params, p_alloc_size);
    for i := 0 to paramcount  do
    begin
      p_add(ParamStr(i));
      ext := Str_ToLow(ExtractFileExt(params[p_size - 1]));
      if  (eqexts_Find(ext)) then
        equalizer.Eq.FRQ_loadfromFile(params[p_size - 1]);
      if (plexts_Find(ext)) then
        PlayList_Load_From_Playlist(params[p_size - 1]);
      if (spexts_Find(ext)) then
        PlayList_add(params[p_size - 1]);
    end;
    Unit1.PlMain.bplayClick(Application);
  end;

begin
  randomize;
  Application.Initialize;
  Application.CreateForm(TPlMain, PlMain);
  Application.CreateForm(TEq, Eq);
  Application.CreateForm(Tpl_vises, pl_vises);
  Application.CreateForm(TForm2, Form2);
  if (paramCount >= 1) then
    RunWithParams;
  Application.Run;


end.
